import Tools as tl
import sys
import numpy as np



def main():
    if len(sys.argv)<1:
        print('no FILE PATH. need file path')
        return
    filePath=sys.argv[1]
    file=tl.read_binary(filePath)
    pageNum=file[0] if len(file.shape)==3 else 1
    for page in range(pageNum):
        img=tl.correct(file[page])
        rows=tl.getCrossPoints_sepByRow(img)
        firstRow=rows[0]
        if len(firstRow)==1:
            print("company_sheet")
            print("passed")
            continue
        else:
            print("account_sheet")
            #识别表名
            basePoint=firstRow[0]
            W=firstRow[1][1]-firstRow[0][1]
            H=rows[1][0][0]-rows[0][0][0]
            TableNameImg=tl.cut(img,basePoint,[H,W])
            TableName=tl.ocr(TableNameImg,"chinese")
            #识别时间
            basePoint1=basePoint
            basePoint1[0]=basePoint[0]-2.7*H
            basePoint1[1]=basePoint[1]+5.4*W
            TableTimeImg=tl.cut(img,basePoint1,[H,W])
            TableTime=tl.ocr(TableTimeImg)
            # 识别





if __name__ == '__main__':
    main()